


/**
 * 
 * 
 * 需要引入js
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/jquery.blockUI/2.70.0-2014.11.23/jquery.blockUI.min.js"></script>
    <script src="assets/js/nier.js"></script>
 */


/**
 * loadingUI配置
 */
$.blockUI.defaults.css = {

    position: 'absolute',

    width: '200px',
    height: '40px',
    left: '0px',
    right: '0px',
    top: '0px',
    bottom: '0px',
    margin: 'auto',
    padding: '2px 10px',
    borderRadius: '2px 2px',
    display: 'flex',

    justifyContent: 'center',
    alignItems: 'center',

    color: '#000',
    border: '3px solid #aaa',
    backgroundColor: '#fff',
    cursor: 'default'

}

/**
 * 
 * 扩展
 * */
$.extend({


    /**
     * 模态框UI过度 loading...
     */
    modal: {
        endTime: 1000,

        /**
         * 
         * loading
         * @param {*} msg  打开提示消息
         */
        loading: function (msg) {
            $.blockUI({
                message: '<div class="box"> <i class="fa fa-spinner fa-spin fa-lg fa-fw margin-bottom"></i> 加载中！ </div>'
            })
        },

        /**
         * 
         * close
         * 关闭提示消息
         */
        close: function () {
            $.unblockUI({
                fadeOut: 200
            })
        },


        /**
         * 
         * success
         * 成功
         */
        success: function (msg) {
            $.blockUI({
                message: '<div class="box"> <i class="  fa fa-check fa-lg fa-fw margin-bottom"></i> ' +
                    msg + '</div>'
            })

            setTimeout(() => {
                $.modal.close();
            }, $.modal.endTime);
        },

        /**
         * 失败信息
         * @param {*} msg 
         */
        error: function (msg) {
            $.blockUI({
                message: '<div class="box"> <i class="fa fa-close fa-lg fa-fw margin-bottom"></i> ' +
                    msg + '</div>'
            })
            setTimeout(() => {
                $.modal.close();
            }, $.modal.endTime);
        },

        /**
         * ajaxBefore
         * @param {*} msg 
         */
        ajaxBefore: function (msg) {
            $.blockUI({
                message: '<div class="box"> <i class="  fa fa-check fa-lg fa-fw margin-bottom"></i> ' +
                    msg + '</div>'
            })


        },


    },


})